package com.soft.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.soft.entity.TOrderitem;
import com.soft.dao.TOrderitemDao;
import com.soft.entity.TProduct;
import com.soft.service.TOrderitemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.security.PublicKey;
import java.util.List;

/**
 * (TOrderitem)表服务实现类
 *
 * @author makejava
 * @since 2021-12-26 14:56:39
 */
@Service("tOrderitemService")
public class TOrderitemServiceImpl implements TOrderitemService {
    @Resource
    private TOrderitemDao tOrderitemDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TOrderitem queryById(Integer id) {
        return this.tOrderitemDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TOrderitem> queryAllByLimit(int offset, int limit) {
        return this.tOrderitemDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tOrderitem 实例对象
     * @return 实例对象
     */
    @Override
    public TOrderitem insert(TOrderitem tOrderitem) {
        this.tOrderitemDao.insert(tOrderitem);
        return tOrderitem;
    }

    /**
     * 修改数据
     *
     * @param tOrderitem 实例对象
     * @return 实例对象
     */
    @Override
    public TOrderitem update(TOrderitem tOrderitem) {
        this.tOrderitemDao.update(tOrderitem);
        return this.queryById(tOrderitem.getIid());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.tOrderitemDao.deleteById(id) > 0;
    }

    public PageInfo<TOrderitem> getOrderItemAndOrderAndProduct(Integer pageNum, Integer pageSize,Integer userId, Integer orderId){
        PageHelper.startPage(pageNum, pageSize);
//        List<TOrderitem> list = this.tOrderitemDao.getOrderItemAndOrderAndProduct(userId, orderId);
//        PageInfo<TOrderitem> pageInfo = new PageInfo<TOrderitem>(list);
        PageInfo<TOrderitem> pageInfo = null;
        return pageInfo;
    }
}